1. /* slmmlp10.cpp by K.Tsuru */
  2. // function ID = 251 DRADIX
  3. /*******************************
  4. SLong class
  5. It multiply by power of ten.
  6. *10^p
  7. p can be negative.
  8. *******************************/
  9. #ifndef SN_H
  10. #include "sn.h"
  11. #endif
  12. static const char* func = "SL MultPow10";
  13. SLong& SLong::MultPow10(long p){
  14. //This is not necessary because an access error occurs for SInteger.
  15. // if(Type() != DRADIX) SetError(RADIX_ERR, func, 251);
  16. if(!p) return *this;
  17. long n = p/DFIGURES, r = p - DFIGURES*n;
  18. long max_sz = (long)MaxSize();
  19. if(n + (long)aTail >= max_sz) SetError(OVERFLOW_ERR, func, 251);
  20. if(r < 0){ n--; r += DFIGURES; } //When p < 0 it makes r > 0.
  21. if(n) MultPowRdx((int)n); //Do not use y *= pow10(p) to avoid the overflow.
  22. if(r) *this = LsMult( *this, (ulong)ipow10((int)r) );
  23. return *this;
  24. }

slmmlp10.cpp : last modifiled at 2015/11/27 14:13:55(833 bytes)
created at 2017/10/07 10:26:50
The creation time of this html file is 2017/11/09 14:52:03 (Thu Nov 09 14:52:03 2017).